'use strict';let _rw=_wj(function*(a){_Pk(a);_lg(a);let d=yield h=>_tl({mouseGest:{},LOCAL:{}},h),e=d.mouseGest||{};_Fh.setEvtLtnrs($("[name=mouseGest]",a)).append(yield _qp(e)).toggleClass("collapsed",_Pt(e));$("[syncSettgs]",a).append(_qu(d.LOCAL));$("[installation]",a).css("display",_hf._So(0)?"initial":"none");_Do&&$("advOpts",a).replaceWith(yield _Ir())}),_qp=_wj(function*(a){a||(a={});return _Bj`\n ${_Ta(a.triggers)}\n <hr>\n ${_4o(a.params)}\n <p>Try your gestures now. <br> Adjust the parameters to obtain the desired accuracy</p>\n <hr>\n ${_6y(a.display)}\n `});
function _Ta(a={}){return _Bj`\n <div name=triggers value={}>\n <fldGrp>\n <fldWrap>\n Perform with: ${_ow([..._hf._2t,["other",{name:"Other"}]].map(([d,e])=>[d,e.name]),a.preset,"preset")} <hw><h h=trig></h></hw>\n </fldWrap>\n ${"other"==a.preset?"<br>":""}\n <fldWrap>\n Timeout: <input type=number name=timeout min=0.2 max=5 step=0.1 value="${a.timeout||1.5}">&nbsp;secs <hw><h h=tOut></h></hw>\n </fldWrap>\n </fldGrp>\n ${"other"==a.preset?_Bj`\n <fldWrap>\n ${_Fh.make(a.begin,"begin",{title:"Begin gesture with: <h h=/gest/bgn></h>",
extraAttrs:"gestureConf noPreconds"})}\n ${_Fh.make(a.end,"end",{title:"End gesture with: <h h=/gest/end></h>",extraAttrs:"gestureConf noPreconds"})}\n </fldWrap>\n `:""}\n &nbsp; &nbsp;\n <precondsWrap>\n ${_Fh.make([{combins:[{eventId:255}],preconds:a.preconds}],"preconds",{extraAttrs:"justPreconds"})}\n <hw><h h=cnd></h></hw>\n </precondsWrap>\n </div>\n `}
function _4o(a={}){return`\n <div name=params value={} popupCntr>\n Gesture precision: ${_Qp({4:"<i mouseGestDirs></i>4 directions",8:"<i mouseGestDirs=8></i>8 directions"},"dirPrecision",a.dirPrecision||8,"","number")} <hw><h h=dir></h></hw>\n Stroke size: <input type=number name=stepSize value="${a.stepSize||50}" min=5 step=5> <hw><h h=stp></h></hw>\n <!--Sensibility: <input type=number name=dirChangeSens value="${a.dirChangeSens||2}" min=1 max=10> <hw><h></h></hw> -->\n <!--Segment size: <input type=number name=segmentSize value="${a.segmentSize||
6}" min=1 max=30> <hw><h></h></hw> -->\n <button testGestureBegin>Test gestures</button>\n <button testGestureEnd>End gesture test</button>\n </div>\n `}
function _6y(a={}){a.enabled=null==a.enabled?!0:a.enabled;return`\n <div name=display value={}>\n <label>${_io("enabled",a.enabled,"hard")}Gesture display</label> <hw><h h=dsp></h></hw>\n <span ${a.enabled?"":"greyedout"}>\n Position:\n ${_ow({M:"Mouse",W:"Window",S:"Screen"},a.posRef,"posRef")}\n ${_ow({C:"Center",T:"Top",B:"Bottom"},a.posAnchor,"posAnchor")}\n <hw><h h=pos></h></hw>\n Size: <input type=number name=size value="${a.size||30}" min=10 max=100 step=2> <hw><h h=siz></h></hw>\n Colors: ${_ow({light:"Light",
dark:"Dark"},a.colors,"colors")} <hw><h h=col></h></hw>\n </span>\n </div>\n `}
function _lg(a){let d=new _do(_Et(function*(e,h){let k=$("[name=toolbarBtns] TBBtnLst",a).html(""),m=0;for(let b of e){e=_5a(b);var n=_Kg(h,b,"icon")||{img:yield _Mr("tbBtn",e+"","#013379","#ffdc7a")};n=_Lu("icon",n,"TBBtn"+b,"tbBtn");k.append(_Bj`\n <TBBtn name=${b}>\n <t>Button ${e}</t>\n Icon: ${n}\n <input type=text name=title value="${_Kg(h,b,"title")}" placeholder="Optional title..." autocomplete=off>\n <del button title="Remove"></del>\n </TBBtn>\n ${++m%2?"":"<br>"}\n `);_Kg(h,b,"icon")||
n.triggerEvt("change",!0)}}));_Jp()(d.onReady());_qf("toolbarBtns")(d.onReady())}
function _qu(a){let d={"":"Off",true:"On"};80<=_Ok&&(d.compress="On (compressed)");a=$(`\n <div><l>Local synchronization:</l> ${_ow({"":"Off",sameBrwr:"Across same browser",allBrwr:"Across all browsers"},a.localSync,"localSync")} <h h=loc></h></div>\n <hr b=4>\n <div><l>Remote synchronization:</l> <c ilnBlk>${_ow(d,a.remoteSync,"remoteSync")} <usg></usg> </c> <h h=rem></h></div>\n `);_Zr($("[name=remoteSync]",a)[0]);return a}
let _Zr=_Et(function*(a){const d=_Ky.storage.sync;let e=100*(yield k=>d.getBytesInUse(k))/d.QUOTA_BYTES|0,h=a.value?`${e}% of ${_jj(d.QUOTA_BYTES)}B`:"";$(a).next().attr("lvl",89<e?"high":75<e?"med":"low").html(h)}),_Yf=_wj(function*(a,d){var e=yield _qf("trigActList","length");let h=_Kg(a,"trigActList","length");if(e&&h){var k=JSON.stringify(yield _2o())==JSON.stringify(a);if(!k)var m=yield _Sa(_ne("confirmSettgsOvrwrt"),{width:"initial"})}if(k)return"sameSettgs";e="cancel"==m;if(!e)if(h&&"useCurr"!=
m)e=!(yield _Hh(a));else return"currSettgs";e&&(d.value="",$(d).triggerEvt("change",!0))}),_Ir=_wj(function*(){let a=yield _qf("advOpts");return $(`\n <section name=${"advOpts"} helpCtx=advOpts class=${a?"":"collapsed"}><h1>Advanced Options <btn></btn></h1>\n ${yield _fe(a)}\n </section>\n `)[0]}),_fe=_wj(function*(a){a={dfltWldcrd:_Ly,ignInjInp:"no",trigRepTime:.6,trigStepTime:1.5}.add(a);let d=[[_Ly,"No wildcard"],[_vg,"On other devices (*)"],[_ak,"On any device (**)"]],e=yield k=>_Ky.extension.isAllowedIncognitoAccess(k),
h=_0;return`\n <div><l>Trigger's default wildcard:</l> ${_ow(d,a.dfltWldcrd,"dfltWldcrd","number")} <h h=wldcrd></h></div>\n <hr>\n <div><l>Ignore synthetic input:</l> ${_ow({no:"Don't ignore",kbd:"Ignore from keyboard",mse:"Ignore from mouse",all:"Ignore all"},a.ignInjInp,"ignInjInp")} <h h=ignInj></h></div>\n <hr>\n <div tight><l>Trigger repetition timeout:</l> <input type=number name=trigRepTime value=${a.trigRepTime} min=0.1 max=5 step=0.1> &nbsp;secs &nbsp; <h h=repTm></h></div>\n <div><l>Trigger steps timeout:</l> <input type=number name=trigStepTime value=${a.trigStepTime} min=0.1 max=5 step=0.1> &nbsp;secs &nbsp; <h h=stpTm></h></div>\n <hr>\n <div externOpt>\n <st ${h?
"on":"off"}></st>\n <cptn>Local page access is ${h?"ON":"OFF"}</cptn> <h h=fileAcc></h> <br>\n Turn it ${h?"off":"on"} in <a href="${_Ce.fileAcc}">this page</a>.\n </div>\n <div externOpt>\n <st ${e?"on":"off"}></st>\n <cptn>Incognito access is ${e?"ON":"OFF"}</cptn> <h h=incgAcc></h> <br>\n Turn it ${e?"off":"on"} in <a href="${_Ce.incogAcc}">this page</a>.\n </div>\n `});const _Gk=new _0g;
function _Pk(a){function d(b){"TBBtnInit"==b&&(e(),_lg(a),n=!1)}function e(){_Ky.runtime.onMessageExternal.removeListener(d);_Ky.windows.remove(m||0,_fy)}_v("mouseGest.triggers.preset",(b,c)=>{$("[name=triggers]",a).replaceWith(_Ta(_Kg(b,...c.slice(0,-1))));_Xd(b)});_v("mouseGest.display.enabled",(b,c)=>{$("[name=display]",a).replaceWith(_6y(_Kg(b,...c.slice(0,-1))))});_v("toolbarBtns.*",(b,c)=>{_ya(+c[c.length-1],_Kg(b,...c))});let h,k;_v("mouseGest.params",(b,c)=>{let f=$("#gestureTestBoard > polyline")[0];
f&&f.points.length&&setTimeout(()=>{_hf._So(_qh,!1);k=2;_hf._So(_qh,_U(f.points[0]));for(let g=1;g<f.points.length;++g)_hf._So(_5r,_U(f.points[g]));_hf._So(_qh,!1)})});let m,n=!0;$(a).on("click","[installTbBtn]",function(){e();let b=$(this).closest("section").find("TBBtn");for(var c=0;c<_Sy.length&&(b.filter(`[name=${c}]`)[0]||c.in(1,2,3,4));++c);let f=_Sy[c];f?_Do?_pd(["toolbarBtns",c+""],{},0,()=>_lg(a)):_yt(_ne("addTBBtnMsg",{attrs:n?"":"noReason"}),{width:"initial"},()=>{let g=Math.min(1200,screen.availWidth);
_Ky.windows.create({url:_Ce.chromeWS+f,focused:!0,type:"popup",left:_ci+(innerWidth-g)/2|0,top:_l+(innerHeight-680)/2|0,width:g,height:680},l=>{m=l.id;_Ky.runtime.onMessageExternal.addListener(d)})}):_yt(_ne("noMoreTBBtns",{maxBtns:_Sy.length}),{width:"initial"})}).on("click","[testGestureBegin]",function(){let b=$("<svg id=gestureTestBoard><g></g><polyline/></svg>").appendTo("body")[0],c=b.firstElementChild,f=b.lastElementChild;$(this).closest("[name=params]").addClass("testGesture");$(window).on("mousemove.gestureTest",
function(g){h&&!k&&(_hf._So(_5r,{x:g.originalEvent.screenX,y:g.originalEvent.screenY}),_Ap(f,_ro,_wi))}).on("focus.gestureTest blur.gestureTest",g=>_hf._Nf("focus"==g.type?{mouseGest:_or("B")}:!1,null));_hf._Nf({mouseGest:_or("B")},(g,l)=>{if(l.state==_or("I"))h=!0,k&&--k||_Ap(f,_ro,_wi,!0),c.innerHTML="";else if(l.state==_or("S"))h=!1;else{g=_Qe(l.len,10,100);let p=_cg(l);l=45*(_Iy(l.dir)-1);c.insertAdjacentHTML("beforeend",`<path d="M-7,7 L0,0 L7,7 M0,5 L0,${g}" transform="translate(${p.x} ${p.y-
g}) rotate(${l} 0 ${g})"/>`)}})}).on("click","[testGestureEnd]",function(){$("#gestureTestBoard").remove();$(this).closest("[name=params]").removeClass("testGesture");$(window).off(".gestureTest");_hf._Nf(!1);h=!1}).on("dblclick","TBBtn del",function(){_pd(_x(this),void 0,0,()=>_lg(a))}).on("click","section > h1 btn",_Et(function*(){let b=$(this).closest("section");if(b.hasClass("collapsed")){let c={mouseGest:_qp,advOpts:_fe},f=b.attr("name");$("> :not(h1)",b).remove();b.append(yield c[f](yield _qf(f)))}else _pd(_x(this),
null,0);b.toggleClass("collapsed")})).on("change","[name=localSync]",_Et(function*(){if(this.value){let b="sameBrwr"==this.value;_Gk.clear();yield _Gk.wait();let c=yield _hf._6t(b);if(yield _Yf(c,this))yield _Zp("add"),yield _hf._Ra(b)}else yield _Zp("del");_hf._Sw(this.value)})).on("change","[name=remoteSync]",_Et(function*(b,c){if(this.value&&"dontSync"!=c){yield _hf._3();let [g,l]=yield _hf._Kr();var f=yield _Yf(g,this);80<=_Ok&&!f&&l&&"true"==this.value&&(this.value="compress",$(this).triggerEvt({change:"dontSync"},
!0))}_hf._Ad(this.value);("currSettgs"==f||"sameSettgs"==f)&&(b=yield _hf._id())&&b.size>b.quota&&(_yt(`\n Your settings require <b>${_jj(b.size,4)}B</b> of storage which exceeds the maximum of <b>${_jj(b.quota)}B</b>\n allowed by your browser's sync service. <hr b=2>\n Remote synchronization won't be possible. ${"compress"==this.value?"":'Try enabling "compressed" mode.'}\n `,{type:"warning"}),this.value="",$(this).triggerEvt("change",!0));_Zr(this)})).on("click","[exportToFile]",()=>{let b=`${_Qg.alias} settings (${_ql(new Date,
"Y-M-D")}).${_mh}`;_ia(c=>_4s(b,JSON.stringify(c)))}).on("click","[importFromFile]",_Et(function*(){let b=yield _Kd(_Tf,"text");_tg(b)})).on("click","[openSttgsFile]",_Et(function*(){let b=yield _Rp("",_0r);b&&_3h(b)})).on("click","[uninstall]",()=>_Ig()).on("click","advOpts",_Et(function*(){let b=yield _Ir();b.style.cssText="opacity: 0; transform: scaleY(0); ";$(this).replaceWith(b);b.scrollIntoView({behavior:"smooth"});yield c=>_Bd(c);b.style.cssText="transform-origin: top; transition: 0.6s"})).on("change",
function(b){if(!$(b.target).parent().closest("[DataModule]")[0]){let c=_x(b.target),f=c.join("."),g=_pu(b.target);"mouseGest.triggers.preconds"==f&&(g=g[0].preconds);b="advOpts"==c[0]||f.endsWith(".timeout")||$(b.target).is("triggers")||f.startsWith("mouseGest.display.")&&!f.endsWith(".enabled")?400:0;_pd(c,g,b,()=>_Gk.send())}})}
let _Ig=_Et(function*(){if(_hf._So(0)){if(yield _Yo("","\n Once the native component is uninstalled, the extension will no longer work. <hr b=2>\n To make it work again, you'll have to re-install the native component by <br> reloading this page. <hr b=2>\n Do you want to uninstall now?\n ",{width:"initial"})){_pg();var a=yield _hf._Od("dir /B *.exe",".",!0);a=[...new Set(a.stdout.trim().split(/\n+/))].map(d=>{d=(d.match(/^[a-z]+/i)||[])[0];return"AutoCtrl"!=d?_Kg(_2f,d,"name"):""}).filter(d=>d);if(a.length&&
(_pg(!1),!(yield _Yo("",`\n The native component is also being used by the following extensions: <hr b=2>\n ${a.map(d=>`<li><b>${d}</b></li>`).join("")} <hr b=4>\n If you uninstall now, those extensions will stop working too. <hr b=2>\n Continue?\n `,{yes:"Yes, uninstall anyway",no:"Cancel",icon:"info"}))))return;_pg();a=`"%tmp%\\${_Q}"`;yield _hf._Od(`copy /Y ${_Fa} /B ${a} && cd .. && ${a} /noConfirm | more & del /F /Q ${a}`);setTimeout(()=>_pg(!1),2E3)}}else _yt("The native component is not installed.",
{type:"error"})});
